log using "log_replication_cps_technocrats.log", replace

*** Supplemental material for 
*** "When technocratic appointments signal credibility"
*****************************************************************************************************
***Analysis conducted using STATA/SE 15.1****
***************************************************
****FILE DIRECTORY

*********************
*********************creating the dataset for the analysis

******CREATING THE AVERAGE ABNORMAL RETURNS(CARs)

clear
*****Preparing the dataset
***opening the ministerial appointment dataset 
use  "EventData.dta"

sort ccode 
by ccode: gen eventcount=_N
by ccode: keep if _n==1
sort ccode
keep ccode eventcount 
save "eventcount.dta", replace
clear

***opening the bond yields dataset 
use "bondav.dta", clear

sort ccode
drop if ccode==8
merge m:m ccode using "eventcount.dta"
tab _merge
keep if _merge==3
drop _merge

expand eventcount

drop eventcount
sort ccode date
by ccode date: gen set=_n
sort ccode set
save "bondav2.dta", replace
clear


use  "EventData.dta", clear
sort ccode
by ccode: gen set=_n
sort ccode set
save "EventData2.dta", replace

clear
use  "bondav2.dta", clear
merge ccode set using  "EventData2.dta"
tab _merge

set more off

list ccode if _merge==2 
keep if _merge==3
drop _merge

egen group_id = group(ccode set)	  

***saving the final dataset that we will use to create AAYs with different estimation windows
save  "CARREADY.dta", replace 

********************************************************************************
********************************************************************************
***************Creating AAYs with different estimation windows******************
********************************************************************************
***Calculating Event and Estimation Windows**(3 DAYS)
clear
use "CARREADY.dta"

***estimating 3 day event windows (7 days)*****
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-3 & dif<=3
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***

gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  

***Abnormal and Average Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1
by id: egen avg_abnormal_yield=mean(abnormal_return)

**dropping duplicates
duplicates drop ccode eventdate, force

**generating dataset
rename avg_abnormal_yield avg3
keep ccode eventdate avg3
gen date=eventdate

sort ccode date

save "avg3.dta", replace

***************
***************
***************
***************
***************
***************


clear
use "CARREADY.dta"

***Calculating Event and Estimation of 90 day Windows**(180 DAYS)
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-90 & dif<=90
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***

gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  


***Abnormal and Average Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1
by id: egen avg_abnormal_yield=mean(abnormal_return)

**dropping duplicates
duplicates drop ccode eventdate, force

**generating dataset
rename avg_abnormal_yield avg90
keep ccode eventdate avg90
gen date=eventdate

sort ccode date

save "avg90.dta", replace
********************
*********************
*********************
***********************
**************
***************
***************

clear
use "CARREADY.dta"

***Calculating Event and Estimation 180day Windows**(360 DAYS)
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-180 & dif<=180
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***


gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  


***Abnormal and Average Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1
by id: egen avg_abnormal_yield=mean(abnormal_return)


**dropping duplicates
duplicates drop ccode eventdate, force

**generating dataset
rename avg_abnormal_yield avg180
keep ccode eventdate avg180
gen date=eventdate

sort ccode date

save "avg180.dta", replace
********************
*********************
*********************
***********************
**************
***************
***************


clear
use "CARREADY.dta"

***Calculating Event and Estimation of 15day Windows**(30 DAYS)
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-15 & dif<=15
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***

gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  

***Abnormal and Average Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1
by id: egen avg_abnormal_yield=mean(abnormal_return)


**dropping duplicates
duplicates drop ccode eventdate, force

**generating dataset
rename avg_abnormal_yield avg15
keep ccode eventdate avg15
gen date=eventdate

sort ccode date

save "avg15.dta", replace


clear
use "CARREADY.dta"

***Calculating Event and Estimation of 45day Windows**(90 DAYS)
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-45 & dif<=45
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***

gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  

***Abnormal and Cumulative Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1
by id: egen avg_abnormal_yield=mean(abnormal_return)


**dropping duplicates
duplicates drop ccode eventdate, force

**generating dataset
rename avg_abnormal_yield avg45
keep ccode eventdate avg45
gen date=eventdate

sort ccode date

save "avg45.dta", replace



******
******creating the full car dataset by merging CARs with different event windows
clear
use "avg3.dta"

merge m:m ccode date using "avg15.dta"
drop _merge

merge m:m ccode date using "avg45.dta"
drop _merge

merge m:m ccode date using "avg90.dta"
drop _merge

merge m:m ccode date using "avg180.dta"
drop _merge

save "AAYs.dta", replace


*****generating 3 day moving average of the average bond yield to estimate the effect of appointments using OLS***

use "bondave_daily.dta"


generate moveave1 = (bondav[_n-2] + bondav[_n-1] + bondav) / 3
generate moveave1f = (bondav[_n+2] + bondav[_n+1] + bondav) / 3
gen dmoveave=moveave1f-moveave1


generate moveave9 = (bondav[_n-8] + bondav[_n-7] + bondav[_n-6] + bondav[_n-5] + bondav[_n-4] + bondav[_n-3] + bondav[_n-2] + bondav[_n-1] + bondav) / 9
generate moveave9f = (bondav[_n+8] + bondav[_n+7] + bondav[_n+6] + bondav[_n+5] + bondav[_n+4] + bondav[_n+3] + bondav[_n+2] + bondav[_n+1] + bondav) / 9
gen dmoveave9=moveave9f-moveave9

save "bondave_ma.dta", replace


**** CREATING THE MAIN DATASET FOR ANALYSIS*******
******************************************************************************************************
***************************************************************
***************************************************************
***********


clear
use "MinisterialData.dta"

****CODING TECHNOCRATS (No parliamentary experience and  Economist)
***********************************************************************

gen noparl=0 if minid3!=.
replace noparl=1 if joinedparliament3==.
replace noparl=0 if preapptpolitics3==3
replace noparl=0 if preapptpolitics3==5
replace noparl=0 if preapptpolitics3==6
replace noparl=0 if preapptpolitics3==7

list name if noparl==1

gen phd=0
replace phd=1 if edulevel3==4 &edusubcat13==1

gen economics=0 if minid3!=.
replace economics=1 if priorprofcat13==1 & edusubcat13==1
replace economics=1 if priorprofcat23==1  & edusubcat13==1
replace economics=1 if priorprofcat33==1 & edusubcat13==1
replace economics=1 if phd==1

gen technocrat=noparl*economics

****CODING TECHNOPOLS
gen technopol=1 if noparl==0 & economics==1
replace technopol=0 if technopol==.

***Coding Partisan Ministers
gen partisan=1 if noparl==0 & technopol!=1
replace partisan=0 if partisan==.

sum technocrat technopol partisan

save "MinisterialDataTechno.dta", replace
****************************************
***************************************

***merge crisis data
***ecb crisis data***
merge m:1 countryname eventdate using "ecb_crisis_events.dta"
**ecb_crisis variable merged***

drop if _merge==2
drop _merge

***Valencia crisis data***
merge m:m countryname year using "Valencia_Crisis.dta"

drop if _merge==2
drop _merge

****Generating crisis interactions

gen technocratcrisis=technocrat*ecb_crisis
gen technopolcrisis=technopol*ecb_crisis


*Generating alternative crisis interactions using the Valencia data***
***coding crisis
gen crisis=0
replace crisis=1 if bankingcrisis==1 | currencycrisis==1 | sovereigndebtcrisis==1 | sovereigndebtrestructuing==1
***coding interactions***
gen technocratcrisis2=technocrat*crisis
gen technopolcrisis2=technopol*crisis

*************************
****Control Variables****
**************************

***Merging data on IMF programs**
merge m:m ccode year using "data_imf.dta"

drop _merge

****Merging data on government partisanship, deficit, inflation from the Comparative Political Dataset/ Armingeon et al**

merge m:m ccode year using "CPDS_debt.dta"
drop if _merge==2
drop _merge

****Merge data on foreign reserve currency**

merge m:m ccode year using "fxreserves.dta"
drop if _merge==2
drop _merge

gen logfx= log(fxreserves)
gen logreserves=log(reserves)

***Merging Capital Account Openness 
merge m:m ccode year using "kaopen.dta"
drop if _merge ==2
drop _merge 

*********generate dummy variable for Central and Eastern Europe****
gen SE_Europe= ccode!=2 & ccode!=3 & ccode!=5 & ccode!=7 & ccode!=15 & ccode!=17 & ccode!=20 & ccode!=6 & ccode!=7 & ccode!=8

***adding EMU countries***
gen EMU=0
replace EMU=1 if countryname=="Austria" & year>1998
replace EMU=1 if countryname=="Belgium" & year>1998
replace EMU=1 if countryname=="Estonia" & year>2010
replace EMU=1 if countryname=="Finland" & year>1998
replace EMU=1 if countryname=="France" & year>1998
replace EMU=1 if countryname=="Germany" & year>1998
replace EMU=1 if countryname=="Greece" & year>2000
replace EMU=1 if countryname=="Ireland" & year>1998
replace EMU=1 if countryname=="Italy" & year>1998
replace EMU=1 if countryname=="Latvia" & year>2013
replace EMU=1 if countryname=="Lithuania" & year>2014
replace EMU=1 if countryname=="Netherlands" & year>1998
replace EMU=1 if countryname=="Portugal" & year>1998
replace EMU=1 if countryname=="Slovakia" & year>2008
replace EMU=1 if countryname=="Slovenia" & year>2007
replace EMU=1 if countryname=="Spain" & year>1998

**simple tranformations of control variables**
sum gov_left2
replace gov_left2=gov_left2/100
sum gov_left2

*********************************************
*********Dependent Variables******************
*********************************************

**Merging AAY data
merge m:m ccode eventdate using "AAYs.dta", force
drop _merge

save "MinistersFull.dta", replace

************************************************************************
*********Merging moving average of average bond yield********************
***************************************************************************

use  "MinistersFull.dta"

merge m:m ccode date using "bondave_ma.dta"
drop if _merge==2
drop _merge



**************************************************
***************************************************
****************************************************
**labels********************************************

label variable technocrat "Technocrat"
label variable crisis "Crisis"
label variable ecb_crisis "Crisis"
label variable technopol "Technopol"
label variable technocratcrisis "Technocrat*Crisis"
label variable technopolcrisis "Technopol*Crisis"
label variable technocratcrisis2 "Technocrat*Crisis"
label variable technopolcrisis2 "Technopol*Crisis"
label variable  cpds_deficit "Deficit"
label variable  Dinflation "Change in Inflation"
label variable  kaopen "Capital A. Openness"
label variable pmchange "Government Change"
label variable gov_left2 "Left Government"
label variable election "Election"
label variable imf "IMF Program"
label variable logreserves "F. Exchange Reserves"
label variable EMU "EMU"

save "MinistersFull.dta", replace

******************************MAIN TEXT**********************************************
******************************MAIN TEXT**********************************************
******************************MAIN TEXT**********************************************
******************************MAIN TEXT**********************************************

**** Replication of Tables and Figures in Main Table, Appendix & Data Appendix*******
******************************************************************************************************
***************************************************************
***************************************************************

******DATA for FIgure 1: Abnormal returns over 20 days
******DATA for FIgure 1: Abnormal returns over 20 days
******DATA for FIgure 1: Abnormal returns over 20 days
******DATA for FIgure 1: Abnormal returns over 20 days

clear
use "CARREADY.dta"

***Calculating Event and Estimation Windows**(20 DAYS)
sort group_id date
by group_id: gen datenum=_n
by group_id: gen target=datenum if date==eventdate
egen td=min(target), by(group_id)
drop target
gen dif=datenum-td


by group_id: gen event_window=1 if dif>=-20 & dif<=20
egen count_event_obs=count(event_window), by(group_id)

by group_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(group_id)

replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.

***Estimating Normal Perfomance with the Bondav***

gen predicted_return=.
egen id=group(group_id)
set more off
forvalues i=1(1)283 {
	l id group_id if id==`i' & dif==0
	reg bondav germanbondav if id==`i' & estimation_window==1 
	predict p if id==`i'
	replace predicted_return = p if id==`i' & event_window==1 
	drop p
}  

***Abnormal Returns
sort id date
gen abnormal_return=bondav-predicted_return if event_window==1

save "CAR20.dta", replace


****CRISIS VARIABLES 

** Crisis Technocrats
clear
 use "CAR20.dta", clear

sort ccode date
merge m:m ccode eventdate using "MinistersFull.dta"
drop _merge


bysort dif : egen mpgmeantechno = mean(abnormal_return) if ecb_crisis==1 & technocrat==1
bysort dif : egen mpgmeantechpol = mean(abnormal_return) if ecb_crisis==1 & technopol==1
bysort dif : egen mpgmeanpart = mean(abnormal_return) if ecb_crisis==1 & partisan==1


save "FullDataset_Figure1.dta", replace

**************
*************
***************************
****Code for Figure 1**** 
 ******with color****
***************************

use "FullDataset_Figure1.dta"

sort dif
   
     line mpgmeantechno  mpgmeantechpol mpgmeanpart dif if dif >-20 & dif<20,  ///
             xtitle(Days from Appointment)  ///
             ytitle(Abnormal returns)                 ///
             lcolor(cranberry dknavy dkgreen)           ///
             lpattern(dash solid dash_dot)                ///
			 lwidth(thick thick thick) ///
             name(pattern2, replace)         ///
		legend(label(1 "Technocrats") label(2 "Technopols") label(3 "Partisans")) ///
 legend(pos(7) ring(0) col(1)) 	 ///
             graphregion(fcolor(white)) ///
			 graphregion(margin(l+2 r+0)) ///
             xsca(titlegap(2)) ///
             ysca(titlegap(4)) ///
             scheme(s2mono) 
			 
graph export "Figure1.pdf", replace 

************************
****Table 1*************
******Main Table*******
************************

use  "MinistersFull.dta"

****main text***
* Table 1 ***
*****************
xtreg avg3 ecb_crisis technocrat  technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t11R1
xtreg avg90 ecb_crisis technocrat technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t12R1
xtreg avg3 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t13R1 
xtreg avg90 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t14R1 
xtreg avg3 ecb_crisis technocrat technocratcrisis gov_left2  cpds_deficit Dinflation kaopen imf EMU logreserves if reshuffle==1, fe 
est sto t15R1 
xtreg avg3  ecb_crisis technocrat technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if SE_Europe, fe 
est sto t16R1 

esttab t11R1  t12R1  t13R1  t14R1 t15R1  t16R1  using table1.tex, se ///
mtitles("7days" "180days" "7days" "180days" "7days" "7days") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis technopol technopolcrisis) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment


*************************
***************************
*****************************************************************
******TABLE 2 main text****************************************************
*****************************************************************

xtreg avg3 gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf logreserves technocrat if ecb_crisis==1,  robust
est sto t21R1
xtreg avg90 gov_left2 pmchange  election cpds_deficit Dinflation kaopen imf logreserves technocrat if ecb_crisis==1,  robust
est sto t22R1
xtreg avg3 gov_left2 pmchange  election cpds_deficit Dinflation kaopen imf logreserves technocrat technopol if ecb_crisis==1, robust
est sto t23R1
xtreg avg90 gov_left2 pmchange  election cpds_deficit Dinflation kaopen imf logreserves technocrat technopol if ecb_crisis==1, robust
est sto t24R1

esttab  t21R1 t22R1 t23R1 t24R1 using table2.tex, se ///
mtitles("7days" "180days" "7days" "180days") ///
label order(gov_left2  pmchange election imf cpds_deficit Dinflation kaopen logreserves technocrat technopol) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses replace fragment

******Figure 2*********************************************************************
*****days in office for technocrats during normal and crises times****
*********************************************************************************** 

use  "MinistersFull.dta"

gen startdate=date(govstartdate, "DMY", 2020)
gen govdate= startdate
format govdate %d

gen enddate=date(gedate, "DMY",2020)
format enddate %d

sort ccode eventdate

by ccode: gen govdatef1=govdate[_n+1]
format govdatef1 %d

by ccode: gen govdatelag=govdate[_n-1]

by ccode: gen minid3lag=minid3[_n-1]

by ccode: gen exit= enddate
by ccode: replace exit= govdatef1 if enddate<govdate
format exit %d

gen newminister=0
replace newminister=1 if minid3~=minid3lag

gen newministerf1=newminister[_n+1]

by ccode: gen min_exit=exit if newministerf1==1
format min_exit %d

by ccode: gen entrydate=.
by ccode: replace entrydate= govdate if newminister==1
by ccode:replace entrydate= entrydate[_n-1] if newminister==0 & entrydate[_n-1]~=.
format entrydate %d

gen gov_id=int(government)
gen gov_idlag=gov_id[_n-1]
by ccode: gen newgov=0
by ccode: replace newgov=1 if gov_id~=gov_idlag

by ccode: gen newgov_entry=govdate if newgov==1
by ccode:  replace newgov_entry=newgov_entry[_n-1] if newgov==0 & newgov_entry[_n-1]~=.
format newgov_entry %d

gen gov_tenure=exit-newgov_entry
gen cab_tenure=exit-govdate
gen min_tenure=min_exit-entrydate
gen min_tenure2= exit-entrydate

*gen didier= minid3==30319

label variable min_tenure "Tenure of Finance Ministers"
label define technocrat 0 "Partisans"
label define technocrat 1 "Technocrats", add
label values technocrat technocrat

label define ecb_crisis 0 "Non-Crisis"
label define ecb_crisis 1 "Crisis", add
label values ecb_crisis ecb_crisis

tabstat cab_tenure gov_tenure, by(crisis)
tabstat min_tenure if didier==0 , by(crisis)
tabstat min_tenure2 if didier==0, by(technocrat)

********Figure 2****
graph bar (mean) min_tenure if didier==0, ///
             over(technocrat) over(ecb_crisis)  ///
			 blabel(bar, format(%20.0f) size(large)) ///
			 bargap(-30) ///
			 ytitle("Days in Office") ///
			 yscale(off) ///
			 ascategory asyvars bar(1,color(gs10)) bar(2, color(gs3)) ///
             name(pattern2, replace)         ///
             legend(pos(7) ring(1) col(1)) 	 ///
             graphregion(fcolor(white)) ///
			 graphregion(margin(l+2 r+0)) ///
			 intensity(90) ///
             scheme(s2mono) 

graph export "Tenure_Ministers.pdf", replace 



****
********Graphs on Country Yields/Elections/Appointments****
*****************************
*****Figure 3***************
*****Figure 3*****************
*****************************
clear
use "dailybonds.dta"
   
********Greece********

tsline t10y if ccode==9 & tin(01jun2012,15jul2012), ///
   xlabel(minmax) ///
   xtitle("Date") ///
   ytitle("10 Year Bond Yield") ///
   scheme(s2mono) ///
   graphregion(fcolor(white)) ///
   title("Market reaction to elections and appoitnment of technocrat", size(3.5)) ///
   subtitle("Greece", size(3)) ///
   tline(17jun2012, lp(solid) lc(black)) tmlabel(17jun2012 "Election", add labsize(*1)) ///
   tline(26jun2012, lp(dash_dot) lc(black)) tmlabel(26jun2012 "Announcement", add labsize(*1.1) labcolor(navy)) ///
   tline(5jul2012, lp(longdash) lc(black)) tmlabel(5jul2012 "Appointment", add labsize(*1.1) labcolor(navy)) tla(, labsize(*.75))
   
graph export "Techno_Market_Greece.pdf", replace 
*******************************
*****Figure 4***********
*****Figure 4**********
*********************************
****Hungary*****
		
tsline t10y if ccode==24 & tin(01april2002,01may2002), ///
   xlabel(minmax) ///
   xtitle("Date") ///
   ytitle("10 Year Bond Yield") ///
   scheme(s2mono) ///
   graphregion(fcolor(white)) ///
   title("Market reaction to elections and appoitnment of technocrat", size(3.5)) ///
   subtitle("Hungary", size(3)) ///
   tline(07apr2002, lp(solid) lc(black)) tmlabel(07apr2002 "1st Election", add labsize(*1))   ///
   tline(21april2002, lp(dash_dot) lc(black)) tmlabel(21april2002 "2nd", add labsize(*1) labcolor(navy)) ///
   tline(23april2002, lp(longdash) lc(black)) tmlabel(23april2002 "Appointment", add labsize(*1) labcolor(navy)) tla(, labsize(*.75)) 
 graph export "Techno_Market_Hungary.pdf", replace 



************************************APPENDIX TABLES ********************
************************************APPENDIX TABLES ********************
************************************APPENDIX TABLES ********************
************************************APPENDIX TABLES ********************
************************************APPENDIX TABLES ********************

use  "MinistersFull.dta"

 *************Desscriptive statistics******************
 *******Table 1************************************
 *********************************************************

estpost tabstat technocrat technopol technocratcrisis technopolcrisis, by(countryname)  stat(mean)
esttab . using table1des.csv, cells("technocrat technopol technocratcrisis technopolcrisis") noobs nostar nomtitle nonumber plain

************Table 2*********
**************Summary statistics*********

estpost sum  technocrat technopol technocratcrisis technopolcrisis avg3 avg15 avg45 avg90 avg180 dmoveave9 gov_left2 pmchange election cpds_deficit Dinflation kaopen imf logreserves EMU
esttab . using table2des.csv, cells("mean sd min max") noobs nonumber nostar plain

**********Table 3*************
*****With Robust Standard Errors*****
**************************************

*Replicating Table 1 of Main text with robust standard errors
xtreg avg3 ecb_crisis technocrat  technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe robust
est sto t11AR1
xtreg avg90 ecb_crisis technocrat technocratcrisis gov_left2    pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe robust
est sto t12AR1
xtreg avg3 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe robust
est sto t13AR1 
xtreg avg90 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe robust
est sto t14AR1 
xtreg avg3 ecb_crisis technocrat technocratcrisis gov_left2  cpds_deficit Dinflation kaopen imf EMU logreserves if reshuffle==1, fe robust
est sto t15AR1 
xtreg avg3  ecb_crisis technocrat technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if SE_Europe, fe robust 
est sto t16AR1 

esttab t11AR1  t12AR1  t13AR1  t14AR1 t15AR1  t16AR1  using table1A1.csv, se ///
mtitles("7days" "180days" "7days" "180days" "7days" "7days") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis technopol technopolcrisis) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

**********Table 4*************
*****With Robust Random Effects*****
**************************************

****
*Replicating Table 1 of Main text with Random Error**
xtreg avg3 ecb_crisis technocrat  technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, re
est sto t11AR1RE
xtreg avg90 ecb_crisis technocrat technocratcrisis gov_left2    pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, re
est sto t12AR1RE
xtreg avg3 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, re
est sto t13AR1RE 
xtreg avg90 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, re
est sto t14AR1RE 
xtreg avg3 ecb_crisis technocrat technocratcrisis gov_left2  cpds_deficit Dinflation kaopen imf EMU logreserves if reshuffle==1, re
est sto t15AR1RE 
xtreg avg3  ecb_crisis technocrat technocratcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if SE_Europe, re
est sto t16AR1RE 

esttab t11AR1RE  t12AR1RE  t13AR1RE  t14AR1RE t15AR1RE  t16AR1RE  using table1A1RE.csv, se ///
mtitles("7days" "180days" "7days" "180days" "7days" "7days") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis technopol technopolcrisis) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment


**********Table 5*************
*****alternative definition of Crisis*****
**************************************

**Replicating Table 1 of main text with alternative definition of Crisis*******
xtreg avg3 crisis technocrat  technocratcrisis2 gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe
est sto t11AR1Crisis
xtreg avg90 crisis technocrat technocratcrisis2 gov_left2    pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe
est sto t12AR1Crisis
xtreg avg3 crisis technocrat technocratcrisis2 technopol technopolcrisis2 gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe
est sto t13AR1Crisis 
xtreg avg90 crisis technocrat technocratcrisis2 technopol technopolcrisis2 gov_left2   pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe
est sto t14AR1Crisis 
xtreg avg3 crisis technocrat technocratcrisis2 gov_left2  cpds_deficit Dinflation kaopen imf EMU logreserves if reshuffle==1,fe
est sto t15AR1Crisis 
xtreg avg3 crisis technocrat technocratcrisis2 gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if SE_Europe, fe
est sto t16AR1Crisis 

esttab t11AR1Crisis  t12AR1Crisis  t13AR1Crisis  t14AR1Crisis t15AR1Crisis  t16AR1Crisis  using table1A1Crisis.csv, se ///
mtitles("7days" "180days" "7days" "180days" "7days" "7days") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves crisis technocrat technocratcrisis2 technopol technopolcrisis2) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

**********Table 6*************
**************************************
***Alternative DV****

xtreg dmoveave9 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t61R1
xtreg dmoveave9 ecb_crisis technocrat technocratcrisis technopol technopolcrisis gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t62R1         
xtreg dmoveave9 ecb_crisis technocrat technocratcrisis   gov_left2  cpds_deficit Dinflation kaopen imf EMU logreserves if reshuffle==1, fe 
est sto t63R1
xtreg dmoveave9 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if SE_Europe, fe 
est sto t64R1 

esttab t61R1 t62R1 t63R1 t64R1 using table1ALT1.csv, se ///
mtitles("D.Yield" "D.Yield" "D.Yield" "D.Yield" "D.Yield" "D.Yield") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis technopol technopolcrisis) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

*********
*********
**************************************************
***********************************************************
****************************************************
****Tables 7a, b, c*******
*****Excluding one country at time******
******3 day windows******************
**************************************************
***********************************************************
****************************************************

set more off
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=2, fe 
est sto ta7a1R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=3, fe 
est sto ta7a2R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=5, fe 
est sto ta7a3R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=6, fe 
est sto ta7a4R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=7, fe  
est sto ta7a5R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves  if ccode!=9, fe  
est sto ta7a6R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=12, fe  
est sto ta7a7R1

xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=15, fe  
est sto ta7b1R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=17, fe  
est sto ta7b2R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=18, fe  
est sto ta7b3R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=19, fe  
est sto ta7b4R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=20, fe  
est sto ta7b5R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=23, fe  
est sto ta7b6R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=24, fe  
est sto ta7b7R1


xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=25, fe  
est sto ta7c1R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=26, fe  
est sto ta7c2R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=27, fe  
est sto ta7c3R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=28, fe  
est sto ta7c4R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=29, fe  
est sto ta7c5R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=31, fe  
est sto ta7c6R1
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves if ccode!=32, fe  
est sto ta7c7R1

esttab ta7a1R1 ta7a2R1 ta7a3R1 ta7a4R1 ta7a5R1 ta7a6R1 ta7a7R1 using table7a1.csv, se ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis) ///
star(* 0.1 ** 0.05 *** 0.01) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

esttab ta7b1R1 ta7b2R1 ta7b3R1 ta7b4R1 ta7b5R1 ta7b6R1 ta7b7R1  using table7b1.csv, se ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis) ///
star(* 0.1 ** 0.05 *** 0.01) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

esttab ta7c1R1 ta7c2R1 ta7c3R1 ta7c4R1 ta7c5R1 ta7c6R1 ta7c7R1  using table7c1.csv, se ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis) ///
star(* 0.1 ** 0.05 *** 0.01) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment


***Table 8****
*****************
*****************
**Different Windows**
xtreg avg3 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t81AR1
xtreg avg15 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t82AR1
xtreg avg45 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t83AR1
xtreg avg90 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t84AR1
xtreg avg180 ecb_crisis technocrat technocratcrisis   gov_left2  pmchange  election cpds_deficit Dinflation kaopen imf EMU logreserves, fe 
est sto t85AR1

esttab t81AR1 t82AR1 t83AR1  t84AR1 t85AR1 using table8A1.csv, se ///
mtitles("7days" "30days" "90days" "180days" "360days") ///
label order(gov_left2  pmchange election imf EMU cpds_deficit Dinflation kaopen logreserves ecb_crisis technocrat technocratcrisis technopol technopolcrisis) ///
star(* 0.10 ** 0.05 *** 0.01) collabels(none) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment




***Table 9A***
***Selecting technocrats****

gen left2crisis=gov_left2*ecb_crisis

xtlogit technocrat gov_left2 ecb_crisis  imf EMU pmchange partiesingovt, vce(robust) 
est sto ta91R1 
xtlogit technocrat gov_left2 ecb_crisis left2crisis  imf EMU pmchange partiesingovt, vce(robust) 
est sto ta92R1 
xtlogit technocrat gov_left2 ecb_crisis left2crisis  imf EMU pmchange partiesingovt, fe  
est sto ta93R1 

esttab ta91R1 ta92R1 ta93R1 using table9R_1.csv, se eform ///
label order(pmchange partiesingovt imf EMU ecb_crisis gov_left2 left2crisis) ///
star(* 0.1 ** 0.05 *** 0.01) ///
stats (N_g N) ///
noabbrev numbers lines parentheses nogap replace fragment

*****************************
*****Figure 1***********
******************************

graph hbox  avg3, over(countryname) yreverse  /// 
                ytitle("Average Abnormal Yield: 3 day window") ///
                title("Abnormal Yield by Country") ///
                scheme(s2mono) ///
                graphregion(fcolor(white))
				graph save "abnormal_yield_hbox", replace
graph export "abnormal_yield_hbox.pdf", replace 


************************************
******End of Do file****************
************************************
*************************************

log close
